<%--
  Created by GHW.
  Date: 2019/11/14
  Time: 18:23
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <link href="css/login.css" rel="stylesheet" type="text/css">
    <script src="js/jquery-2.2.4.min.js"></script>
    <meta charset="UTF-8">
    <title>登录</title>
    <script type="text/javascript">
        $(function () {
            $(".btn").click(function () {
                var username = $("#username").val();//取值
                var password = $("#password").val();
                if (!username) {
                    alert("用户名必填!");
                    $("#username").focus();//获取焦点
                    return;
                }
                if (!password) {
                    alert("密码必填!");
                    $("#password").focus();//获取焦点
                    return;
                }
                var userType;
                $('.userType>input').each(function () {
                    if (($('#admin').prop('checked')) == true) {
                        userType = $('#admin').val()
                    } else if (($('#user').prop('checked')) == true) {
                        userType = $('#user').val()
                    }
                });
            });
        });
    </script>
</head>
<body>
<form id="box" runat="server" class="login-box" method="post" action="UserLoginServlet">
    <h1>登陆</h1>
    <div class="textbox">
        <label for="username"><input type="text" id="username" placeholder="请输入用户名" name="username"/></label>
    </div>
    <div class="textbox">
        <label for="password"><input type="password" id="password" placeholder="请输入密码" name="password"/></label>
    </div>
    <div class="userType">
        <label for="admin"><input type="radio" name="userType" id="admin" value="admin">管理员</label>
        <label for="user"><input type="radio" name="userType" id="user" value="user">用户</label>
    </div>
    <input class="btn" type="submit" value="登录" id="loginBtn" runat="server" onserverclick="Click">

    <a href="register.html"><input type="button" value="注册" id="logon"></a>
</form>
</body>
</html>